package com.example.exception;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class GlobalExceptionHandler {

    /*@ExceptionHandler(ChatException.class)
    public ResponseEntity<String> handleChatException(ChatException ex) {
        // 记录错误日志
        System.err.println("Ollama 模型调用失败: " + ex.getMessage());
        // 返回友好的错误提示
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
                .body("抱歉，模型调用失败，请检查 Ollama 服务是否正常运行。");
    }
*/
    @ExceptionHandler(Exception.class)
    public ResponseEntity<String> handleGeneralException(Exception ex) {
        // 记录错误日志
        System.err.println("系统错误: " + ex.getMessage());
        // 返回通用错误提示
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
                .body("系统发生错误，请稍后再试。");
    }
}